package com.tmt.im.service.mapstruct;

import com.tmt.im.common.pojo.ChatSessionPoJo;
import com.tmt.im.service.controller.vo.ChatSessionDetailVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description TODO
 * @Author wuyi
 * @Date 2024/9/16 22:46
 * @Version 1.0
 **/
@Component
@Mapper(componentModel = "spring")
public interface ChatSessionPoJoMapStruct {

    @Mappings({
            @Mapping(target = "type", expression = "java(com.tmt.im.service.helper.ChatSessionPoJoHelper.getType(poJo.getType()))"),
            @Mapping(target = "inviteState", expression = "java(com.tmt.im.service.helper.ChatSessionPoJoHelper.getInviteState(poJo.getJoinMode()))"),
            @Mapping(target = "shutupState", expression = "java(com.tmt.im.service.helper.ChatSessionPoJoHelper.getShutupState(poJo.getChatBanned()))"),
            @Mapping(target = "nonCollectionState", source = "poJo.allowRedPackage")
    })
    ChatSessionDetailVo toChatSessionDetailVo(ChatSessionPoJo poJo);

    List<ChatSessionDetailVo> toChatSessionDetailVos(List<ChatSessionPoJo> sessionPoJos);

}
